""" 
    twExtJS - ToscaWidgets wrapper for ExtJS (see http://extjs.com)
    
    Distributed under the terms of Lesser GNU Public License.
    
    (c) 2007 - Ricardo Girardi Sixel 
"""

from toscawidgets.core import Widget

class Record(Widget):
    template = "mako:toscawidgets.widgets.extJS.templates.data.record"
    name = 'record'
    params = ['name','data']
    def __init__(self,data=[]):
        self.data = data
        
class JSONReader(Widget):
    template = "mako:toscawidgets.widgets.extJS.templates.data.jsonreader"
    record = None
    root = ''
    totalProperty=  ''
    name='jsonreader'
    idField = ''    
    params = ['record','root','name','idField','totalProperty']
    
class SortInfo:
    field = 'field'
    direction = 'ASC' # ASC or DESC    
    def __init__(self,field='field',direction='ASC'):
        self.field = field
        self.direction = direction

class Store(Widget):
    componentId = 'store'
    template = "mako:toscawidgets.widgets.extJS.templates.data.store"
    name = 'store' 
    url = ''
    reader = None
    sortInfo = None
    params = ["autoLoad","name","reader","sortInfo","url","newRecordUrl","componentId"]
    newRecordUrl = ''
    autoLoad=False 

class JSONStore(Store):
    fields = []
    record = None
